/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('openapiexplorer', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model GetErrorCodeSolutionsRequest {
  acceptLanguage?: string(name='acceptLanguage'),
  errorCode?: string(name='errorCode', description='This parameter is required.', example='1234-56789012'),
  errorMessage?: string(name='errorMessage', example='An error occurred while processing your request.'),
  product?: string(name='product', example='oss'),
}

model GetErrorCodeSolutionsResponseBody = {
  requestId?: string(name='requestId'),
  solutions?: [ 
    {
      content?: string(name='content'),
      errorCode?: string(name='errorCode', example='0017-00000502'),
      errorMessage?: string(name='errorMessage'),
      product?: string(name='product'),
      productName?: string(name='productName'),
      solutionId?: string(name='solutionId', example='0017-00000502'),
    }
  ](name='solutions'),
}

model GetErrorCodeSolutionsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetErrorCodeSolutionsResponseBody(name='body'),
}

/**
 * @summary 根据提供的错误码获取对应的解决方案
 *
 * @description ## 请求说明
 * - 本接口支持通过POST或GET方法调用。
 * - `Accept-Language`请求头必须设置为`zh-CN`或`en-US`之一，用于指定返回结果的语言类型。
 * - 错误码格式需符合特定规则，特别是针对OSS的错误码应遵循正则表达式`[0-9]{4}-[0-9]{8}`。
 * - 当前实现中未使用`maxResults`和`nextToken`参数。
 * - 如果请求失败，将根据不同的错误情况返回相应的错误代码及描述信息。
 *
 * @param request GetErrorCodeSolutionsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetErrorCodeSolutionsResponse
 */
async function getErrorCodeSolutionsWithOptions(request: GetErrorCodeSolutionsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetErrorCodeSolutionsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.acceptLanguage)) {
    query['acceptLanguage'] = request.acceptLanguage;
  }
  if (!Util.isUnset(request.errorCode)) {
    query['errorCode'] = request.errorCode;
  }
  if (!Util.isUnset(request.errorMessage)) {
    query['errorMessage'] = request.errorMessage;
  }
  if (!Util.isUnset(request.product)) {
    query['product'] = request.product;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetErrorCodeSolutions',
    version = '2024-11-30',
    protocol = 'HTTPS',
    pathname = `/getErrorCodeSolutions`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 根据提供的错误码获取对应的解决方案
 *
 * @description ## 请求说明
 * - 本接口支持通过POST或GET方法调用。
 * - `Accept-Language`请求头必须设置为`zh-CN`或`en-US`之一，用于指定返回结果的语言类型。
 * - 错误码格式需符合特定规则，特别是针对OSS的错误码应遵循正则表达式`[0-9]{4}-[0-9]{8}`。
 * - 当前实现中未使用`maxResults`和`nextToken`参数。
 * - 如果请求失败，将根据不同的错误情况返回相应的错误代码及描述信息。
 *
 * @param request GetErrorCodeSolutionsRequest
 * @return GetErrorCodeSolutionsResponse
 */
async function getErrorCodeSolutions(request: GetErrorCodeSolutionsRequest): GetErrorCodeSolutionsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getErrorCodeSolutionsWithOptions(request, headers, runtime);
}

model GetOwnRequestLogRequest {
  logRequestId?: string(name='logRequestId', description='This parameter is required.', example='123E4567-E89B-12D3-A456-426614174000'),
}

model GetOwnRequestLogResponseBody = {
  logInfo?: {
    authenticationInfo?: {
      authenticationType?: string(name='authenticationType'),
      signatureMethod?: string(name='signatureMethod', example='HMAC-SHA256'),
      signatureVersion?: string(name='signatureVersion'),
    }(name='authenticationInfo'),
    basicInfo?: {
      accessDeniedDetail?: {
        authAction?: string(name='authAction'),
        authPrincipalDisplayName?: string(name='authPrincipalDisplayName'),
        authPrincipalOwnerId?: string(name='authPrincipalOwnerId'),
        authPrincipalType?: string(name='authPrincipalType'),
        encodedDiagnosticMessage?: string(name='encodedDiagnosticMessage'),
        noPermissionType?: string(name='noPermissionType'),
        policyType?: string(name='policyType'),
      }(name='accessDeniedDetail'),
      api?: string(name='api'),
      apiDoc?: {
        alibabacloudSite?: string(name='alibabacloudSite'),
        aliyunSite?: string(name='aliyunSite'),
      }(name='apiDoc'),
      apiStyle?: string(name='apiStyle'),
      apiVersion?: string(name='apiVersion'),
      endpoint?: string(name='endpoint'),
      errorCode?: string(name='errorCode'),
      errorMessage?: string(name='errorMessage'),
      gatewayProcessTime?: string(name='gatewayProcessTime'),
      httpMethod?: string(name='httpMethod'),
      httpStatusCode?: string(name='httpStatusCode'),
      logRequestId?: string(name='logRequestId'),
      product?: string(name='product'),
      productName?: {
        cnName?: string(name='cnName'),
        enName?: string(name='enName'),
      }(name='productName'),
      regionId?: string(name='regionId'),
      requestDuration?: string(name='requestDuration'),
      sdkRequestTime?: string(name='sdkRequestTime'),
      throttlingResult?: string(name='throttlingResult'),
    }(name='basicInfo'),
    callerInfo?: {
      callerAccountId?: string(name='callerAccountId'),
      callerIp?: string(name='callerIp'),
      callerType?: string(name='callerType'),
      masterAccountId?: string(name='masterAccountId'),
      userAgent?: string(name='userAgent'),
    }(name='callerInfo'),
    parameters?: [ 
      {
        name?: string(name='name'),
        required?: boolean(name='required'),
        type?: string(name='type'),
        value?: any(name='value'),
      }
    ](name='parameters'),
    responses?: {
      responseBody?: string(name='responseBody'),
      responseBodyFormat?: string(name='responseBodyFormat'),
    }(name='responses'),
  }(name='logInfo'),
  requestId?: string(name='requestId'),
}

model GetOwnRequestLogResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetOwnRequestLogResponseBody(name='body'),
}

/**
 * @summary 通过API RequestId 查询当前账号调用OpenAPI的日志详情，用于故障排查。
 *
 * @description ## 请求说明
 * - 本接口主要用于帮助用户通过提供具体的`apiRequestId`来获取相关API请求的详细日志信息。
 * - `apiRequestId`必须是大写形式的UUID，并且应确保该ID确实来自于您之前对某个OpenAPI的实际调用。
 * - 如果提供的`apiRequestId`无效或者没有找到对应的日志记录，系统将返回相应的错误提示。
 * - 在使用此接口时，请注意检查您的网络环境以及权限设置，以保证能够顺利访问到所需资源。
 *
 * @param request GetOwnRequestLogRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetOwnRequestLogResponse
 */
async function getOwnRequestLogWithOptions(request: GetOwnRequestLogRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetOwnRequestLogResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.logRequestId)) {
    query['logRequestId'] = request.logRequestId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetOwnRequestLog',
    version = '2024-11-30',
    protocol = 'HTTPS',
    pathname = `/getOwnRequestLog`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 通过API RequestId 查询当前账号调用OpenAPI的日志详情，用于故障排查。
 *
 * @description ## 请求说明
 * - 本接口主要用于帮助用户通过提供具体的`apiRequestId`来获取相关API请求的详细日志信息。
 * - `apiRequestId`必须是大写形式的UUID，并且应确保该ID确实来自于您之前对某个OpenAPI的实际调用。
 * - 如果提供的`apiRequestId`无效或者没有找到对应的日志记录，系统将返回相应的错误提示。
 * - 在使用此接口时，请注意检查您的网络环境以及权限设置，以保证能够顺利访问到所需资源。
 *
 * @param request GetOwnRequestLogRequest
 * @return GetOwnRequestLogResponse
 */
async function getOwnRequestLog(request: GetOwnRequestLogRequest): GetOwnRequestLogResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getOwnRequestLogWithOptions(request, headers, runtime);
}

model GetRequestLogRequest {
  logRequestId?: string(name='logRequestId', description='This parameter is required.', example='123E4567-E89B-12D3-A456-426614174000'),
}

model GetRequestLogResponseBody = {
  logInfo?: {
    authenticationInfo?: {
      authenticationType?: string(name='authenticationType', example='AK'),
      signatureMethod?: string(name='signatureMethod', example='HMAC-SHA256'),
      signatureVersion?: string(name='signatureVersion', example='unknown'),
    }(name='authenticationInfo'),
    basicInfo?: {
      accessDeniedDetail?: {
        authAction?: string(name='authAction', example='openapiexplorer:GetRequestLog'),
        authPrincipalDisplayName?: string(name='authPrincipalDisplayName', example='205618123456123456'),
        authPrincipalOwnerId?: string(name='authPrincipalOwnerId', example='1001234561234567'),
        authPrincipalType?: string(name='authPrincipalType', example='SubUser'),
        encodedDiagnosticMessage?: string(name='encodedDiagnosticMessage', example='-'),
        noPermissionType?: string(name='noPermissionType', example='ImplicitDeny'),
        policyType?: string(name='policyType', example='AccountLevelIdentityBasedPolicy'),
      }(name='accessDeniedDetail'),
      api?: string(name='api', example='RunInstances'),
      apiDoc?: {
        alibabacloudSite?: string(name='alibabacloudSite', example='https://api.alibabacloud.com/document/Ecs/2014-05-26/RunInstances'),
        aliyunSite?: string(name='aliyunSite', example='https://api.aliyun.com/document/Ecs/2014-05-26/RunInstances'),
      }(name='apiDoc'),
      apiStyle?: string(name='apiStyle', example='roa'),
      apiVersion?: string(name='apiVersion', example='2024-11-30'),
      endpoint?: string(name='endpoint', example='ecs.cn-hangzhou.aliyuncs.com'),
      errorCode?: string(name='errorCode', example='IncorrectStatus.TransitRouter'),
      errorMessage?: string(name='errorMessage', example='The resource is not in a valid state for the operation.'),
      gatewayProcessTime?: string(name='gatewayProcessTime', example='2025-01-21T07:43:06Z'),
      httpMethod?: string(name='httpMethod', example='GET'),
      httpStatusCode?: string(name='httpStatusCode', example='404'),
      logRequestId?: string(name='logRequestId', example='123E4567-E89B-12D3-A456-426614174000'),
      product?: string(name='product', example='Ecs'),
      productName?: {
        cnName?: string(name='cnName'),
        enName?: string(name='enName', example='Elastic Compute Service'),
      }(name='productName'),
      regionId?: string(name='regionId', example='cn-hangzhou'),
      requestDuration?: string(name='requestDuration', example='188'),
      sdkRequestTime?: string(name='sdkRequestTime', example='2025-01-21T07:43:06Z'),
      throttlingResult?: string(name='throttlingResult', example='FC.PASS'),
    }(name='basicInfo'),
    callerInfo?: {
      callerAccountId?: string(name='callerAccountId', example='241009849925897811'),
      callerIp?: string(name='callerIp', example='100.68.xxx.xxx'),
      callerType?: string(name='callerType', example='sub'),
      masterAccountId?: string(name='masterAccountId', example='1973374733454118'),
      userAgent?: string(name='userAgent', example='AlibabaCloud API Workbench'),
    }(name='callerInfo'),
    parameters?: [ 
      {
        name?: string(name='name', example='InstanceType'),
        required?: boolean(name='required', example='false'),
        type?: string(name='type', example='string'),
        value?: any(name='value', example='ecs.g6.large'),
      }
    ](name='parameters'),
    responses?: {
      responseBody?: string(name='responseBody', example='-'),
      responseBodyFormat?: string(name='responseBodyFormat', example='JSON'),
    }(name='responses'),
  }(name='logInfo'),
  requestId?: string(name='requestId', example='9BFC4AC1-6BE4-5405-BDEC-CA288D404812'),
}

model GetRequestLogResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetRequestLogResponseBody(name='body'),
}

/**
 * @summary 通过API请求ID查询特定请求的日志详情，用于故障排查。
 *
 * @description ## 请求说明
 * - 本接口主要用于帮助用户通过提供具体的`apiRequestId`来获取相关API请求的详细日志信息。
 * - `apiRequestId`必须是大写形式的UUID，并且应确保该ID确实来自于您之前对某个OpenAPI的实际调用。
 * - 如果提供的`apiRequestId`无效或者没有找到对应的日志记录，系统将返回相应的错误提示。
 * - 在使用此接口时，请注意检查您的网络环境以及权限设置，以保证能够顺利访问到所需资源。
 *
 * @param request GetRequestLogRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetRequestLogResponse
 */
async function getRequestLogWithOptions(request: GetRequestLogRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetRequestLogResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.logRequestId)) {
    query['logRequestId'] = request.logRequestId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetRequestLog',
    version = '2024-11-30',
    protocol = 'HTTPS',
    pathname = `/getRequestLog`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 通过API请求ID查询特定请求的日志详情，用于故障排查。
 *
 * @description ## 请求说明
 * - 本接口主要用于帮助用户通过提供具体的`apiRequestId`来获取相关API请求的详细日志信息。
 * - `apiRequestId`必须是大写形式的UUID，并且应确保该ID确实来自于您之前对某个OpenAPI的实际调用。
 * - 如果提供的`apiRequestId`无效或者没有找到对应的日志记录，系统将返回相应的错误提示。
 * - 在使用此接口时，请注意检查您的网络环境以及权限设置，以保证能够顺利访问到所需资源。
 *
 * @param request GetRequestLogRequest
 * @return GetRequestLogResponse
 */
async function getRequestLog(request: GetRequestLogRequest): GetRequestLogResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getRequestLogWithOptions(request, headers, runtime);
}

